home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / il / ilThread.z / ilThread
Encoding:
Text File  |  2002-10-03  |  8.1 KB  |  265 lines

  1.  
  2.  
  3.  
  4. iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))        IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll        iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      iiiillllTTTThhhhrrrreeeeaaaadddd - share group process
  10.  
  11.  
  12. IIIINNNNHHHHEEEERRRRIIIITTTTSSSS FFFFRRRROOOOMMMM
  13.      iflListItem : ilThreadItem
  14.  
  15.  
  16. HHHHEEEEAAAADDDDEEEERRRR FFFFIIIILLLLEEEE
  17.      #include <il/ilThread.h>
  18.  
  19.  
  20. CCCCLLLLAAAASSSSSSSS DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.      ilThread is a wrapper class for the sproc() system call.
  22.  
  23. CCCCLLLLAAAASSSSSSSS MMMMEEEEMMMMBBBBEEEERRRR FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN SSSSUUUUMMMMMMMMAAAARRRRYYYY
  24.      CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr
  25.  
  26.           ilThread(ilThreadRtn* rtn, void* arg=NULL)
  27.           ilThread(pid_t pid=0)
  28.  
  29.      SSSSyyyynnnnccccrrrroooonnnniiiizzzzaaaattttiiiioooonnnn mmmmeeeetttthhhhooooddddssss
  30.  
  31.           static int block()
  32.           static int unblock(pid_t pid)
  33.           int unblock()
  34.           static void shutdown()
  35.  
  36.      GGGGeeeetttt////sssseeeetttt mmmmeeeetttthhhhooooddddssss
  37.  
  38.           static pid_t getCurrentPID()
  39.           pid_t getPID()
  40.           static ilThread* getCurrentThread()
  41.           static int numProcessors()
  42.           static ilArena* getArena()
  43.           void setRoutine(ilThreadRtn* rtn, void* arg=NULL) _p_r_o_t_e_c_t_e_d
  44.  
  45.      TTTThhhhrrrreeeeaaaadddd pppprrrriiiivvvvaaaatttteeee mmmmeeeemmmmoooorrrryyyy aaaallllllllooooccccaaaattttiiiioooonnnn
  46.  
  47.           static void allocPrivate(void*& data, int size)
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))        IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll        iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))
  71.  
  72.  
  73.  
  74. FFFFUUUUNNNNCCCCTTTTIIIIOOOONNNN DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNNSSSS
  75.      iiiillllTTTThhhhrrrreeeeaaaadddd(((())))
  76.  
  77.           ilThread(ilThreadRtn* rtn, void* arg=NULL)
  78.           ilThread(pid_t pid=0)
  79.  
  80.  
  81.           The first contructor invokes sproc with PR_SADDR to create new
  82.           thread that will start execution at the routine indicate by _r_t_n. The
  83.           routine will be passed _a_r_g as its only parameter.  The second
  84.           constructor wraps an ilThread around the existing share group
  85.           process indicated by _p_i_d.
  86.  
  87.      aaaallllllllooooccccPPPPrrrriiiivvvvaaaatttteeee(((())))
  88.  
  89.           static void allocPrivate(void*& data, int size)
  90.  
  91.  
  92.           This static method allocates a piece of thread private data.  This
  93.           is a very primitive feature intended for modules that need permanent
  94.           thread private storage; there is no mechanism for freeing the data
  95.           once it is allocated.  This routine is race-condition free if used
  96.           as show here:
  97.  
  98.               static void* pvtData=NULL;
  99.               if (pvtData == NULL) ilThread::allocPrivate(pvtData, pvtSize);
  100.  
  101.  
  102.           Although the pvtData pointer will hold the same address for all
  103.           threads, the memory it points to will be private in each thread
  104.           (through the modern miracle of virtual memory mappings).
  105.  
  106.      bbbblllloooocccckkkk(((())))
  107.  
  108.           static int block()
  109.  
  110.  
  111.           This static method blocks the calling thread until uuuunnnnbbbblllloooocccckkkk()ed by
  112.           another thread.  It is okay for a thread to be unblocked before it
  113.           has blocked. In this case the thread will no actually block, it will
  114.           just continue executing.  This is extremely useful in avoiding nasty
  115.           race conditions.
  116.  
  117.      ggggeeeettttAAAArrrreeeennnnaaaa(((())))
  118.  
  119.           static ilArena* getArena()
  120.  
  121.  
  122.           This static method returns an ilArena shared memory handle that is
  123.           used with the ilSpinLock and ilSemaphore routines by default.
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))        IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll        iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))
  137.  
  138.  
  139.  
  140.      ggggeeeettttCCCCuuuurrrrrrrreeeennnnttttPPPPIIIIDDDD(((())))
  141.  
  142.           static pid_t getCurrentPID()
  143.  
  144.  
  145.           This is a lightweight static method that returns the pid of the
  146.           current thread.
  147.  
  148.      ggggeeeettttCCCCuuuurrrrrrrreeeennnnttttTTTThhhhrrrreeeeaaaadddd(((())))
  149.  
  150.           static ilThread* getCurrentThread()
  151.  
  152.  
  153.           This static method returns a pointer to the ilThread object
  154.           associated with the calling thread (or NULL if there is none).
  155.  
  156.      ggggeeeettttPPPPIIIIDDDD(((())))
  157.  
  158.           pid_t getPID()
  159.  
  160.  
  161.           This method returns the pid of this thread (the object it is invoked
  162.           on, not the calling thread).
  163.  
  164.      nnnnuuuummmmPPPPrrrroooocccceeeessssssssoooorrrrssss(((())))
  165.  
  166.           static int numProcessors()
  167.  
  168.  
  169.           This static method returns the number of processors on the system
  170.           that the calling process is running on.
  171.  
  172.      sssseeeettttRRRRoooouuuuttttiiiinnnneeee(((())))
  173.  
  174.           void setRoutine(ilThreadRtn* rtn, void* arg=NULL) _p_r_o_t_e_c_t_e_d
  175.  
  176.  
  177.           This method initializes the entry point and argument for a thread.
  178.           This is mainly for use in derived classes.
  179.  
  180.      sssshhhhuuuuttttddddoooowwwwnnnn(((())))
  181.  
  182.           static void shutdown()
  183.  
  184.  
  185.           This method shuts down all of the ilThreads created by this
  186.           application.
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))        IIIImmmmaaaaggggeeeeVVVViiiissssiiiioooonnnn LLLLiiiibbbbrrrraaaarrrryyyy CCCC++++++++ RRRReeeeffffeeeerrrreeeennnncccceeee MMMMaaaannnnuuuuaaaallll        iiiillllTTTThhhhrrrreeeeaaaadddd((((3333))))
  203.  
  204.  
  205.  
  206.      uuuunnnnbbbblllloooocccckkkk(((())))
  207.  
  208.           int unblock()
  209.           static int unblock(pid_t pid)
  210.  
  211.  
  212.           This first version of this routine unblocks the process
  213.           corresponding to this object.  This seconv version unblocks the
  214.           process indicate by _p_i_d.
  215.  
  216. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  217.      ilMpSetMaxProcs(3), IL(1), sproc(1)
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.